<?php 
    $product = new Default_Model_Product();
    $percent = 100 - (($this->data['sales_price'] / $this->data['original_price']) * 100);
    $save = $this->data['original_price'] - $this->data['sales_price'];

	$targetYear  = $this->data['expiry_year'];
	$targetMonth = $this->data['expiry_month'];
	$targetDay   = $this->data['expiry_day'];
	$targetHour  = $this->data['expiry_hour'];
	$targetMinute= $this->data['expiry_minute'];
	$targetSecond= $this->data['expiry_second'];

    $dateFormat = "Y-m-d H:i:s";
    
    $targetDate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear);
    $actualDate = time();
    
    $secondsDiff = $targetDate - $actualDate;
    
    $remainingDay     = floor($secondsDiff/60/60/24);
    $remainingHour    = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
    $remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
    $remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));
    
    $targetDateDisplay = date($dateFormat,$targetDate);
    $actualDateDisplay = date($dateFormat,$actualDate);
?>
<script type="text/javascript">
  var days = <?php echo $remainingDay; ?>  
  var hours = <?php echo $remainingHour; ?>  
  var minutes = <?php echo $remainingMinutes; ?>  
  var seconds = <?php echo $remainingSeconds; ?>  

function setCountDown ()
{
  seconds--;
  if (seconds < 0){
      minutes--;
      seconds = 59
  }
  if (minutes < 0){
      hours--;
      minutes = 59
  }
  if (hours < 0){
      days--;
      hours = 23
  }
  if(days < 0)
  {
    document.getElementById("remain").innerHTML = "Thời gian còn lại: Đã hết hạn";
  }
  else
  {
    document.getElementById("remain").innerHTML = "Thời gian còn lại: "+days+" ngày "+hours+" giờ "+minutes+" phút "+seconds+" giây";
  }
  setTimeout ( "setCountDown()", 1000 );
}

</script>
<!--Begin All-->
    <div class="d_all">
    	
    <!--Menu-->
  <div class="tt_menu_2">
 	<div class="pl20 pt10">
    <?php echo $this->ProductCat(); ?>
    </div>
    <?php echo $this->render('/search_product.phtml'); ?>
  </div>
                    
    <!--End Menu-->
    
    <!--Begin Contents-->
    <div class="d_contents_wrap_2">
    	<div class="d_space_height_10"></div>
		
        <!-- Left -->
        <div class="dd_ctsp">
        
        <div class="ttct_top">
            <div class="pl20"><?php echo $this->data['cat_name']; ?></div>
        </div>

    <div class="dd_ctsp_mid">
        <div class="pa20">
            <div class="product_details">
                <a class="title_details"><?php echo $this->data['product_name']; ?></a>
                
                <div style="clear: both;">
                    <div class="left_details">                                   
                        <img class="image_details" src="<?php echo $this->baseUrl('/public/files/product/') . $this->data['product_image']; ?>" />
                    </div>
                    
                    <div class="right_details">
                        <div class="price_details">
                            <div class="sales_details">
                                <center>
                                    <?php echo $product->formatMoney($this->data['sales_price']); ?>đ
                                </center>
                            </div>
                            
                            <a class="buy_btn" href="<?php echo $this->data['product_link']; ?>"  target="_blank"></a>
                            
                            <div class="original_details">
                                <center>
                                Giá gốc: <?php echo $product->formatMoney($this->data['original_price']); ?>đ
                                </center>
                            </div>
                            
                            <div class="bot">
                                <div class="percent_details">
                                    <center>
                                        <p>Giảm</p>
                                        <p style="font-size: 16px;"><?php echo $product->percent($percent); ?>%</p>
                                    </center>
                                </div>
                                
                                <div class="save_details">
                                    <center>
                                        <p>Tiết kiệm</p>
                                        <p style="font-size: 16px;"><?php echo $product->formatMoney($save); ?>đ</p>
                                    </center>
                                </div>
                            </div>
                        </div>
                        
                        <div class="time_details" id="remain">
                            <?php echo "Thời gian còn lại: $remainingDay ngày $remainingHour giờ $remainingMinutes phút $remainingSeconds giây";?>
                        </div>
                        
                        <div class="bottom_details">
                            <div class="area_details">
                                <center><?php echo $this->data['area_name']; ?></center>
                            </div>
                            
                            <div class="cont_details">
                                <a class="cont_btn"></a>
                            </div>
                        </div>
                    </div>
                    
                    <div style="clear: both;"></div>
                    
                        <script> 
                          FB.init({appId: "394487913951162", status: true, cookie: true});
                    
                          function postToFeed() {
                    
                            // calling the API ...
                            var obj = {
                              method: 'feed',
                              link: '<?php echo 'http://localhost:81' . $this->userAgent()->getServerValue('request_uri'); ?>',
                              picture: 'http://www.umarket.vn/public/files/product/<?php echo $this->image; ?>',
                              caption: '<?php echo $this->data['cat_name']; ?>',
                              name: '<?php echo $this->title; ?>',
                              description: '<?php echo $this->description; ?>'
                            };
                    
                            function callback(response) {
                              document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
                            }
                    
                            FB.ui(obj, callback);
                          }
                        
                        </script>
                    
                    <div class="like_button">
                        <a style="display: block; cursor: pointer; width: 20px;" onclick='postToFeed(); return false;'><img src="<?php echo $this->baseUrl('/public/files/Facebook_icon.png'); ?>" /></a>
                    </div>                    
                    
                    <div class="like_button">
                        <a href="https://plus.google.com/share?url=<?php echo 'http://localhost:81' . $this->userAgent()->getServerValue('request_uri'); ?>" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;"><img style="width: 20px; height: 20px;" src="https://www.gstatic.com/images/icons/gplus-32.png" alt="Share on Google+"/></a>
                    </div>
                    
                    <div class="like_button">
                        <div class="g-plusone" data-size="medium" data-href="<?php echo 'http://localhost:81' . $this->userAgent()->getServerValue('request_uri'); ?>"></div>
                    </div>
                    
                    <div class="like_button" style="margin-left: 0;">
                        <fb:like send="false" layout="button_count" width="150" show_faces="true" font="arial"></fb:like>
                    </div>
                    
                    <div style="clear: both;"></div>
                    
                    <div class="content_details">
                        <table class="table_details" cellspacing="0">
                            <tr>
                                <td class="table_details_td1"><span class="heading_product">Ưu điểm của sản phẩm</span></td>
                                <td class="table_details_td2"></td>
                                <td class="table_details_td1" style="padding-left: 20px;"><span class="heading_product">Điều kiện sử dụng</span></td>
                            </tr>
                            <tr>
                                <td class="table_details_td1"><?php echo $this->data['product_advantages']; ?></td>
                                <td class="table_details_td2"></td>
                                <td class="table_details_td1" style="padding-left: 20px;"><?php echo $this->data['product_conditions']; ?></td>
                            </tr>
                        </table>
                        
                        <div class="product_content">
                            <p class="heading_product">Chi tiết sản phẩm</p>
                            <?php echo $this->data['product_content']; ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="dd_ctsp_bot"></div>
    
    <!-- Binh luan -->
            <div class="ttct_top">
                <div class="pl20">Bình luận</div>
            </div>
            
            <div class="dd_ctsp_mid">
                <div class="pa20">
                    <div class="comment">
                        <form action="" method="">                            
                            <textarea class="cmt_content" name="cmt_content"></textarea>
                            <input class="button" type="submit" name="submit" value="Bình luận" />
                            
                            <div class="cmt_total">
                                Hiện tại có <span class="msg">3</span> bài bình luận.
                            </div>
                            
                            <div class="comments">
                                <div class="user_cmt">greentree</div>
                                <div class="content_cmt">
                                    Chào các chị. Em dự định thi văn bằng 2 tiếng Anh nhưng bỏ lâu quá rồi cũng hơi run tay. Có chị nào có tài liệu hay dạng đề của văn bằng 2 không ạ? Các chị giúp em với nhé. Em cảm ơn
                                </div>
                                <div class="msg">45 phút trước</div>
                            </div>
                            
                            <div class="comments">
                                <div class="user_cmt">bap2310</div>
                                <div class="content_cmt">
                                    bạn thi văn bằng 2 của trường gì vậy?mình cũng đang tính học nè,b có thể ra nhà sách mua INTERNATIONAL EXPRESS về ôn đó b
                                </div>
                                <div class="msg">6 giờ trước</div>
                            </div>
                            
                            <div class="comments">
                                <div class="user_cmt">cocogau</div>
                                <div class="content_cmt">
                                    mình có sách đó nè lấy ko cuốn của mnh là pre-inter ah
                                </div>
                                <div class="msg">11 giờ trước</div>
                            </div>
                            
                            
                        </form>
                    </div>
                </div>
            </div>
        <div class="dd_ctsp_bot"></div>
    </div>